package dao;

import bean.Readroom;
import util.Linksql;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;

public class ReadroomDao {
    Connection connection=null;
    Statement std=null;
    ResultSet resultSet=null;
    public List<Readroom> getAll() {
        connection= Linksql.getConnection();
        List list = new ArrayList();
        String sql = "select * from readroom_funm";
        try{
            std=connection.createStatement();
            resultSet = std.executeQuery(sql);
            while (resultSet.next()){
                Readroom seat = new Readroom();
                seat.setReadroomnum(resultSet.getString("readroomnum"));
                seat.setUsestatus(resultSet.getString("usestatus"));
                seat.setAreaname(resultSet.getString("areaname"));
                seat.setFnum(resultSet.getString("fnum"));
                list.add(seat);
            }
            resultSet.close();
            std.close();
            connection.close();
        } catch (SQLException throwables){
            throwables.printStackTrace();
        }
        return list;
    }
}
